package com.ms.p2p.controller.admin;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ms.p2p.bean.PageBean;
import com.ms.p2p.controller.BaseController;
import com.ms.p2p.provider.RedPacketLogProvider;
import com.ms.p2p.utils.JsonDataGridHelper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;

/**
 * Created by chensk on 2017/11/22.
 */
@Controller("RedPacketLogController")
@RequestMapping({"/admin/redpacketlog"})
public class AdminRedPacketLogController extends  AdminBaseController{

    @Reference
    private RedPacketLogProvider redPacketLogProvider;


    @RequestMapping({"/list"})
    public String list(Model model, PageBean page) throws IllegalAccessException,
            InvocationTargetException, IntrospectionException {

        return "/admin/redpacket/log/list";
    }


    @RequestMapping({"/queryData"})
    @ResponseBody
    public PageBean queryData(Model model, PageBean page) throws IllegalAccessException,
            InvocationTargetException, IntrospectionException {
        page.setList(redPacketLogProvider.findPager(page));
        page.setTotalCount(redPacketLogProvider.findCount());
        return JsonDataGridHelper.createJSONData(page);
    }


    @Override
    public boolean getBinderFlag() {
        return true;
    }
}
